using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Dapper.Contrib.Extensions;
using Publicuse.Entity;
using Publicuse.Entity.AttributeUtil;
using SqlSugar;

namespace Publicuse.Entity
{
  /// <summary>
  /// 资源信息
  /// </summary>
  [DBTable("`geeker-menu`", "权限资源")]
  [Table("`geeker-menu`")]
  [SugarTable("`geeker-menu`")]
  public partial class Menu : BaseModel<long>
  {
    [Remark("组件路径")]
    public string component { get; set; }

    [Remark("语言编码")]
    public string language { get; set; }

    [Remark("是否显示在后台菜单")]
    public string isShow { get; set; }

    [Remark("资源名称")]
    public string aName { get; set; }

    [Remark("二级菜单名称")]
    public string abName { get; set; }

    [Remark("二级菜单图标")]
    public string abIcon { get; set; }

    [Remark("二级菜单索引")]
    public int abIndex { get; set; } = -1;

    [Remark("资源编码")]
    public string aCode { get; set; }

    [Remark("资源接口Url")]
    public string aapiUrl { get; set; }

    [Remark("资源页面Url")]
    public string ahtmlUrl { get; set; }

    [Remark("模块索引")]
    public int amoduleIndex { get; set; } = -1;

    [Remark("资源图标")]
    public string ahtmlIcon { get; set; }

    /// <summary>
    /// 所属上级编号
    /// </summary>
    [Remark("所属上级编号")]
    public long aParentId { get; set; } = -1;

    [Remark("资源类型")]
    public int aType { get; set; } = -1;

    [Remark("1-是 2-否；是否生成对应的查询、修改、新增、删除、导入、导出、下载模板、回收站权限资源判断")]
    public string aisCURD { get; set; }

    [Remark("是否一键生成前台后台代码 1=是 2=否")]
    [Write(false)]
    [NoQuery]
    [SugarColumn(IsIgnore = true)]
    public int isedit { get; set; } = -1;

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public bool ischecked { get; set; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public List<Menu> children { get; set; }

    public Menu()
    {
      this.Id = 0;
      this.aisCURD = "-1";
    }
  }

  public class MenuSimple
  {
    public string ahtmlUrl { get; set; }
    public string aName { get; set; }
  }

  public class MenuTree : Menu
  {
    public long key { get; set; }

    public bool expand { get; set; } = false;

    public bool havechildren { get; set; } = false;

    public List<MenuTree> children { get; set; }
  }

  /// <summary>
  /// 资源查询参数
  /// </summary>
  public class MenuQuery : CommonQuery
  {
    public int aId { get; set; }
    public string aName { get; set; }

    public string acTime { get; set; }

    public int aType { get; set; }

    public MenuQuery()
    {
      this.exportName = GetExportName;
      this.businessType = BusinessType.menu;
    }

    public static string GetExportName
    {
      get { return "authority"; }
    }
  }

  /// <summary>
  /// 登录账号模块功能权限
  /// </summary>
  public class UserFunctionMenu
  {
    /// <summary>
    /// 是否有新增权限
    /// </summary>
    public bool isadd { get; set; } = false;

    /// <summary>
    /// 是否有删除权限
    /// </summary>
    public bool isdelete { get; set; } = false;

    /// <summary>
    /// 是否有修改权限
    /// </summary>
    public bool isupdate { get; set; } = false;

    /// <summary>
    /// 是否有查询权限
    /// </summary>
    public bool isquery { get; set; } = false;

    /// <summary>
    /// 是否有导入权限
    /// </summary>
    public bool isimport { get; set; } = false;

    /// <summary>
    /// 是否有导出权限
    /// </summary>
    public bool isexport { get; set; } = false;

    /// <summary>
    /// 是否有下载权限
    /// </summary>
    public bool isdown { get; set; } = false;

    /// <summary>
    /// 是否有上传权限
    /// </summary>
    public bool isupload { get; set; } = false;

    /// <summary>
    /// 是否有审核权限
    /// </summary>
    public bool iscomfirm { get; set; } = false;

    /// <summary>
    /// 是否有绑定角色资源的权限
    /// </summary>
    public bool isroleresource { get; set; } = false;

    /// <summary>
    /// 是否有绑定企业的权限
    /// </summary>
    public bool iscompany { get; set; } = false;

    /// <summary>
    /// 是否有绑定部门的权限
    /// </summary>
    public bool isdepartment { get; set; } = false;

    /// <summary>
    /// 是否有绑定学校的权限
    /// </summary>
    public bool isschool { get; set; } = false;

    /// <summary>
    /// 是否有回收站的权限
    /// </summary>
    public bool isrecyclebin { get; set; } = false;
  }

  public class AuthorityMenu
  {
    public int id { get; set; } = 0;

    public string menuName { get; set; }

    public string code { get; set; } = string.Empty;

    public int fatherId { get; set; }
    public int orderNum { get; set; }
    public string path { get; set; } = string.Empty;
    public string menuType { get; set; }
    public bool visible { get; set; } = false;
    public int status { get; set; }
    public string icon { get; set; } = string.Empty;
    public string alIcon { get; set; } = string.Empty;
    public bool newLinkFlag { get; set; } = false;
    public string createTime { get; set; } = string.Empty;
    public string updateTime { get; set; } = string.Empty;

    public string cTime { get; set; } = string.Empty;
    public string uTime { get; set; } = string.Empty;

    public string aisCURD { get; set; } = string.Empty;

    public string isShow { get; set; } = string.Empty;
  }

  public class UserRouteData
  {
    public List<UsermenuPermissions> routes { get; set; } = new List<UsermenuPermissions>();
    public string home { get; set; } = string.Empty;
  }

  public class UsermenuPermissions
  {
    public string name { get; set; } = string.Empty;
    public string path { get; set; } = string.Empty;
    public string component { get; set; } = string.Empty;
    public umpMeta meta { get; set; } = new umpMeta();

    public List<UsermenuPermissions> children { get; set; } = new List<UsermenuPermissions>();
  }

  public class umpMeta
  {
    public string title { get; set; } = string.Empty;
    public string icon { get; set; } = string.Empty;
    public string i18nKey { get; set; } = string.Empty;
    public int order { get; set; } = 0;
    public bool keepAlive { get; set; } = false;
  }

  public class MenuTreeb
  {
    public string title { get; set; }
    public string value { get; set; }
    public int sort { get; set; }
    public List<MenuTreeb> children { get; set; }
  }

  public class MenuTreec
  {
    public string title { get; set; }
    public string key { get; set; }
    public int sort { get; set; }
    public bool ischecked { get; set; } = false;
    public bool isexpand { get; set; } = false;
    public List<MenuTreec> children { get; set; }
  }

  public enum PermissionType
  {
    CATALOGUE = 1,
    MENU = 2,
    BUTTON = 3
  }

  public class UserMenuAction
  {
    public string menuCode { get; set; }
    public string menuName { get; set; }
  }

}
